package leetcode.每日一题;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/11/17 10:02 PM
 * @description：
 */
public class 判断子序列 {
    @Test
    public void test() {
        System.out.println(new Solution().isSubsequence("abc", "ahbgdc"));
    }

    class Solution {
        public boolean isSubsequence(String s, String t) {
            int i = 0, j = 0;
            while (i < s.length() && j < t.length()) {
                if (s.charAt(i) == t.charAt(j)) {
                    i++;
                }
                j++;
            }
            return i == s.length();
        }
    }
}
